TVToys Version 1.1 October 1993 Far Niente Productions Contents Ü ßßßßßßßßßßßßß Introduction Copyright Short Description Package File List Instructions Turbo Pascal 6.0 Users Compatibility Testing Coding Style Protected Mode Information Overlay Information Video 7 The Improved Help File Extended Video Mode Support Code The NewMouse unit Credits Author, Support, Info, Bugs etc To Do List Introduction Ü ßßßßßßßßßßßßßßßßß Welcome to TVToys! This is a collection of useful stuff that should be available to all Turbo Vision programmers. It is intended for Turbo Pascal 7.0 but would be possible to port to TP6. THE SOURCE IS FREE AND COMES WITH NO WARRANTIES WHATSOEVER. I hope that you will find this package useful. Have fun with it! Copyright Ü ßßßßßßßßßßßßßß You may use this package for free and pass it on to other persons as long as you clearly state, in the header as well as in the code, all changes made to the original code. You may not pass along compiled versions of the source, except as executable files. You may also upload this package, unmodified, to bulletin boards or other public access places. If you do, please try to keep the upload current. There must be no charge associated with this package, though you may include the unmodified package as a whole in shareware/freeware compilations if only a nominal amount is charged for the compilation disk. Short Description Ü ßßßßßßßßßßßßßßßßßßßßßß This package includes: An improved Help viewer with back tracking and the possibility to add Contents and Index pages or whatever without recompiling HelpFile. Extended video mode support. Code that determines what video modes are available and presents a list for the user to choose from. Video7 and VESA support included. A mouse unit that limits the effects of buggy mouse drivers in extended video modes. Two demonstration programs. Lots of commented code, tried and tested. Package File List Ü ßßßßßßßßßßßßßßßßßßßßßß The package consists of the following files: HELPFILE.PAS Improved HelpFile with back tracking and external commands HELPTEST.PAS Demonstration of HelpFile HELPCTX.PAS Help contexts generated by TVHC HELPTEST.HLP Demo Help text compiled with TVHC HELPTEST.TXT The Help text source VIDEO.PAS A unit supporting extended video mode setting and scanning MODEDLG.PAS Dialog for presenting and selecting video modes MODEDLG.DLG The dialog as saved by Dialog Design TVVIDEO.PAS TV support for all the new video modes VIDEOTST.PAS Demonstration of Video, ModeDlg and TVVideo IMPRTANT.PAS Warning dialog used by VideoTst NEWMOUSE.PAS Snap in replacement mouse cursor for extended video modes COLORTXT.PAS Enhanced static texts with color. Mini shadows DPMI.PAS DPMI assembler programming simplication code VESA.PAS VESA support routines TIP.TXT Assortment of unrelated information. README.TXT This text. Instructions Ü ßßßßßßßßßßßßßßßßß There are two demo programs, VIDEOTST and HELPTEST. All you have to do is compile and run them for a quick demonstration. You have to explicitly define "Video7Support" and "VESASupport" if that's what you want. Remember to BUILD every time you change conditionals. If your mouse behaves oddly at times when running VIDEOTST, try uncommenting NewMouse from the uses statement in VIDEOTST.PAS. (The mouse cursor jumps around when you change video modes, but that's because the cursor stays at the same position relative to the upper left corner) If you use VIEWS.TPU/TPP as shipped by Borland, you can try to define Color before compiling and running VIDEOTST.PAS. This spiffs up the Info Dialog and demonstrates ColorTxt. Read the header in each source file to get more information, VIDEOTST.PAS especially. Turbo Pascal 6.0 users Ü ßßßßßßßßßßßßßßßßßßßßßßßßßßß All the code can be converted for use with Turbo Pascal 6.0, if you are desperate. The worst problem is that Borland Pascal 7.0 clears the data segment before the program starts, which I make heavy use of. This means that the code won't work as intended even if it compiles with TP6. Off hand, I can think of VideoList, VesaVersion, VesaScanningSupported, OldFront and OldCount causing trouble. I have seen code that clears the data segment for you, though. I have a patched TP6 HelpFile (using the old help file format) if you are interested. VIDEOTST.PAS uses an Application^.ExecuteDialog, check out TVEDIT.PAS in your TP6 TVDEMOS directory for an equivalent ExecDialog procedure. You might want these, too: const Seg0040 : Word = $0040; SegB000 : Word = $B000; SegB800 : Word = $B800; Compatibility Testing Ü ßßßßßßßßßßßßßßßßßßßßßßßßßß This code has mainly been tested on three machines: þ A 286 with with a Chips VGA card and an EGA monitor. Also tested with a Video7 card which provided 132 column output on the EGA monitor. No protected mode. First development machine. þ An IBM PS/1 486/33 with Tseng VGA chips. VERY slow at scanning. First protected mode attempts. þ A Dual monitor Compaq 386 Portable with a Video7 VGA card and Super VGA monitor. Current development platform. VESA compatibility was tested using a PD Video7 TSR on the 386. UNIVESA.EXE by Kendall Bennett is NOT a full VESA implementation, it focuses solely on graphics video modes and will not provide the necessary information to avoid having to physically test every video mode. If you promptly have to use UNIVESA or UNIVBE release 4.1 or earlier on a Video 7 video card, make sure you define V7UniVesaKludge, since there is a Video 7 specific bug in UNIVESA. Future versions of UNIVESA will probably not suffer from this. Coding Style Ü ßßßßßßßßßßßßßßßßß Oh well, I do my best. I have tried to change my usual style slightly, for your sake. I started using fully qualified names, so you would know where to look for the code. I now realize the browser will be of much more help, so the qualified names are gone. There is no need to use fully qualified names, as there are no name collisions. I also started writing "Byte" instead of "byte", and so on for word, boolean etc, but I doubt that I am consistently using that style. The Video and VESA code is littered with {$IFDEF} for VESA, V7 and DPMI support. I might make full support mandatory and remove all but the DPMI IFDEFs. Let me know what you think. I can't think of a nice way to code TMain.HandleEvent. There are some comments there, be aware of what happens or expect trouble when you port the code to your application. I have changed the names of most procedures at least once, so there might be references to old names in the documentation. Some code has been moved, so some references to files might be misleading. I have tried to spot most errors. You will probably feel that I am overindenting my code, sigh. Protected Mode Information Ü ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß The code was originally developed and tested on a 286 without protected mode support. Recently, development moved to a 386 with 4 Mb of memory and a Video7 VGA card. All the code has been tested in protected mode, especially the Video7, Vesa and NewMouse code, and it works for me... Overlay Information Ü ßßßßßßßßßßßßßßßßßßßßßßßß You can overlay all units EXCEPT NewMouse, which contains an interrupt handler. It's a very small unit anyway, about 430 bytes in real mode. Video 7 Ü ßßßßßßßßßßßß This package supports Video 7 video cards. Certain design decisions were made with Video 7 in mind (overly complicating things). Video 7 cards do not recognize any non standard video modes if you use the normal BIOS interrupt call, you must use a special Video 7 call. On the other hand, video mode 1 corresponds to the last EXTENDED video mode set with such a Video 7 call. This also means that if you ask a Video 7 BIOS in the normal way what video mode is set, the answer will be 1 for all extended video modes. This creates problems as mode 1 is a standard 40x25 mode. Sometimes you will get a 40x25 mode when you least expect it, usually when you terminate your program abnormally inside the IDE. This only happens if you have a Video 7 video card, mind you. The Improved Help File Ü ßßßßßßßßßßßßßßßßßßßßßßßßßßß HELPFILE.PAS is an improved help file with back tracking and custom key help screens. See HELPTEST.PAS for a demonstration. The HelpFile code is a modified TP7 HelpFile with some bugs removed. There should be no difficulty upgrading your programs to use the improved HelpFile. Move the HelpInUse variable into the Application object and paste the PopHelp and GetEvent procedures in HELPTEST.PAS into your application to use the improved HelpFile. Of course, you need to define a few commands as well. Extended Video Mode Support Code Ü ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß The units Video, ModeDlg, TVVideo and VESA provide extended video mode support. See VIDEOTST.PAS for a demonstration. If you want to support Video7 VGA cards, make sure you define Video7Support before you compile VIDEO.PAS. If you want VESA support, define VesaSupport before you compile VIDEO.PAS. If you define both VesaSupport and Video7Support, VESA calls are used first. CheckVideoType will still look for all video types supported, though. How it all works: First call CheckVideoType. This will set VideoType, Video7 and VesaVersion to appropriate values. If VesaVersion is zero, no Vesa support was detected. Call SetupVideoList to construct a list of available video modes. If a VESA video card is detected, attempts will be made to directly inquire about available video modes. This might not be supported by the video card since it is not mandatory in the VESA standard. If the VESA test fails, ScanEVGAModes will be used to determine video modes. ScanEVGAModes takes a somewhat simple and stupid approach to determine what video modes are available: It tries to set every video mode from 0 to 127 to see if the BIOS responds by setting more or less legal values in the BIOS data segment. This might not work all that well all the time, see VIDEOTST.PAS for a list of caveats. The only other way (apart from VESA) of determining available video modes is to use lists of all video modes for all cards manufactured. Use SelectVideoModeDialog to put up a TV dialog that lets the user choose between available modes. To avoid unnecessary scanning, you can use the SaveVideoModes and LoadVideoModes commands to save and restore the scanning results to/from disk. If you don't like the format of the information (not very easy to read, maybe?) presented in the selection dialog, make changes in the AddMode procedure in MODEDLG.PAS. To use the video mode routines, use this as a checklist: 1) Always start out by determining the current video system. CheckVideoType; (* Always start with this command *) 2) Check that we're in fact dealing with a EGA/VGA before using ScanEVGAModes. You can simply shut off the command: if VideoType=Other then DisableCommands([cmVideoMode, cmVideoLines, cm14p, cm16p]); 3) Put up some sort of warnings before we start scanning... HasToScan is false if we already know what video modes are available. VesaScanningSupported is true if we don't have to physically set every video mode to see if it is supported. You might want to put up different warnings depending on what will actually happen. See VIDEOTST.PAS for a simple example. 4) To scan and then select video mode: SetupVideoList; SelectVideoModeDialog; If you use resources, do it this way: SetupVideoList; SelectVideoMode( PSelectVideoModeDialog(RezFile.Get('VideoModeDialog'))); 5) To save the video modes found during scanning, use StoreVideoModes: var S : TDosStream; S.Init('VIDEOTST.INI', stCreate); StoreVideoModes(S); S.Done; Use LoadVideoModes to restore them. 6) Remember to change all your old references to SetScreenMode to SetSpecialScreenMode, often used to switch between 25 and 43/50 lines. 7) DON'T use smFont8x8 if you use VesaSupport, you MUST use smSpecialFont8x8 instead. 8) Remember that this code has to trash Turbo Vision's StartUpMode to get by "internal security", so you must save and restore StartUpMode yourself if you want to return to the start up mode when your program exits. Since Video7 cards use video mode 1 to signify the last extended video mode used, special care must be taken to provide intelligent StartupMode behaviour if Video7Support is defined. See VIDEOTST.PAS for a demonstration using VideoState objects. The NewMouse unit Ü ßßßßßßßßßßßßßßßßßßßßßß NewMouse is a quick and dirty solution for buggy mouse drivers that don't know a thing about any video modes except the "standard" ones. If you have a Logitech mouse driver, you will probably never have any problems, but others will. Many mouse drivers have problems with video modes they are not familiar with. They might not let the cursor travel across all the screen, or worse, think that what is in fact a text mode is a graphics mode and present a "graphics mode" mouse cursor. NewMouse simply contains its own routines for drawing a mouse cursor. NewMouse relies on BIOS information to determine the width of the screen. The screen is always assumed to be in text mode. If you want to switch to graphics mode, you have to take some precautions. See NEWMOUSE.PAS. NewMouse has no hardware cursor support, so the cursor will always be drawn in the standard text mode way. You cannot change the appearance of the mouse cursor without turning NewMouse off by using UseNewMouse(False). Since NewMouse solely focuses on drawing a mouse cursor, there will still be a text mode mouse cursor if you run a TV application windowed (not full screen) in Windows enhanced mode. Looks funny. Don't know what to do about it. Just add NewMouse FIRST in your main program's USES statement to use it. You CANNOT overlay the NewMouse unit. Credits Ü ßßßßßßßßßßßß All dialogs designed and generated with Dialog Design 4.0 available on Compuserve and by anonymous ftp to garbo.uwasa.fi in directory /pc/turbovis and Simtel20, oak.oakland.edu in /pub/msdos/turbovis. Thanks to David Baldwin, who also contributed the original ColorTxt unit. I finally found a VESA TSR for Video7 that contained TEXT mode support. Thanks to Gary Lorenson. All Video7 and VESA information derived from Ralf Brown's famous interrupt listing. DPMI information from Borland source and Ralf Brown's interrupt listing. This project would have been utterly impossible without the help of Borlands run time source, or for that matter, Borland Pascal 7.0... Author, Support, Info, Bugs etc Ü ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß If you would like to see further enhancements to this code, write me a letter telling me what you like and don't like, what works and what doesn't, and what improvements you want to see. Since I am a computer science student with no income, I would very much appreciate a financial contribution. Get in touch with me if you feel that you want to support this package financially. Unfortunately I can't take checks, since they'd cost me a small fortune a piece to cash in. Bug reports, enhancements, contributions, credits, postcards and money are always welcome! My internet address: d91-pbr@nada.kth.se You can reach me from CompuServe by sending mail to: INTERNET:d91-pbr@nada.kth.se Mail: Peter Brandstr”m (Peter Brandstrom) Roslagsgatan 10 S-113 55 Stockholm Sweden, Europe To Do List Ü ßßßßßßßßßßßßßßß Help context management for the video mode scanning dialog, perhaps. Video mode selection dialog help texts produced by native English speaking person, to go with it. Volunteers? More toys? (I have a 64K+ editor under construction)